// component/modular/index.js
const api = require('../../config/home.js');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    informationCategorys: {
      type: Object,
      value: [],
      observer: function (newVal) {
        // 属性值变化时执行
        this.getClassifyList(newVal)
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    informations: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    gomore(options) {
      let classify = options.currentTarget.dataset.dictvalue
      let value = options.currentTarget.dataset.value
      let label = options.currentTarget.dataset.label
      console.log("点击 ",value,label,classify)
      if(value != '4'){
        wx.navigateTo({
          url: `/pages/information/informationList/index?classify=${classify}&classification=${value}&classifyName=${label}`
        })
      }else{
        wx.navigateTo({
          url: `/pages/laoLai/index`
        })
      }
     
    },
    getClassifyList(list) {
      if (list && list.length) {
        let arr = []
        list.forEach(item => {
          let informationTypes = JSON.parse(item.remark || '[]')
          if (informationTypes && informationTypes.length) {
            informationTypes = informationTypes.slice(0,4)
            informationTypes.forEach(x=>x.label = x.label.substring(0,3))
            arr.push({
              dictLabel:item.dictLabel,
              dictValue:item.dictValue,
              informationTypes:informationTypes
            })
          }
        })
        this.setData({
          informations: arr
        })
      }
    }
  }
})
